
require(ggplot2)

setwd("/Users/zimaoxiao/Dropbox/CC_Yield_Predict/replication_package/")

table2 = read.csv("data/figure/Figure2.csv",stringsAsFactors = T)

ggplot() +
  geom_boxplot(outlier.colour="black", outlier.shape=16,
               outlier.size=2, notch=FALSE)

png("output/Figure2.png", units="px", width=4000, height=1200, res=300)
ggplot(table2, aes(y=factor(row_name),x=m,group=row,color=factor(color))) +
  geom_boxplot(outlier.size = .1, width=0.3) +
  #geom_hline(yintercept = 0, linetype=2) +
  #facet_wrap(~rcp) +
  #ylim(-4,4) +
  xlab("Crop Yields (bu/acre)") + ylab("") +
  scale_y_discrete(limits=rev) +
  scale_color_manual(name = "Spec",values=c("black","#F46F43","#80A6E2")) +
  theme_bw() + theme(legend.title = element_blank(), 
                     legend.position = "none",
                     text = element_text(size=20),
                     axis.title.x=element_text(size=16),
                     axis.text.y = element_text(hjust = 0),
                     panel.grid.major = element_blank(),
                     panel.grid.minor = element_blank(),
                     strip.background =element_rect(fill="white"))
dev.off()


table3 = read.csv("data/figure/Figure3.csv",stringsAsFactors = T)

png("output/Figure3.png", units="px", width=4600, height=1800, res=300)
ggplot(table3, aes(y=factor(row_name),x=m,group=row,color=factor(color))) +
  geom_boxplot(outlier.size = .1,width=.3) +
  #geom_hline(yintercept = 0, linetype=2) +
  #facet_wrap(~rcp) +
  #ylim(-4,4) +
  xlab("Crop Yields (bu/acre)") + ylab("") +
  scale_y_discrete(limits=rev) +
  scale_color_manual(name = "Spec",
                     values=c("black","#F46F43","#80A6E2","#CF3D3E","#403990")) +
  theme_bw() + theme(legend.title = element_blank(), 
                     legend.position = "none",
                     #legend.direction = "vertical",
                     text = element_text(size=20),
                     axis.title.x=element_text(size=16),
                     axis.text.y = element_text(hjust = 0),
                     panel.grid.major = element_blank(),
                     panel.grid.minor = element_blank(),
                     strip.background =element_rect(fill="white"))
dev.off()
